$(function(){
	time();
});

function time() {
	var dates = new Date();
	var year = dates.getFullYear();	//年
	var month = dates.getMonth();	//月
	var date = dates.getDate();  	//日
	var hours = dates.getHours();	//时
	var minutes = dates.getMinutes();//分
	var seconds = dates.getSeconds();//秒
	$(".da_t_time input").val(year+"-"+month+"-"+date+" "+hours+":"+minutes+":"+seconds);
}
var potsum = 0;
var zjsum = 0;
function addpot () {
	var zjiname = $("#zjiname").val();
	var zjisum = $("#zjisum").val();
	var zjiid = $("#zjiid").val();
	var jinid = $("#jinid").val();
	if(zjiname==""){
		alert("没有填写成员");
		return;
	}else if(zjisum==""){
		alert("没有确认数量");
		return;
	}else if(jinid==0){
		alert("请选择员工职业");
		return;
	}
	potsum = potsum+parseInt(zjisum);
	zjsum++;
	var html = "<div><a id='potname' class='len'>"+zjiname+"</a>"+
		"<a id='potsum' class='len'>"+zjisum+"</a>"+
		"<a id='zji' class='len' style='display: none;'>"+zjiid+"</a><br/>"+
		"<a id='jin' class='len' style='display: none;'>"+jinid+"</a></div>";
	$(".da_t_pots").append(html);
}
function adddept() {
	var deptname = $("#deptname").val();
	var deptid = $("#deptid").val();
	var empid = $("#empid").val();
	var depttext = $("#depttext").val();
	var emp = $(".He_text_t").attr("id");
	if(deptname==""){
		alert("部门名未确定！");
		return;
	}else if(depttext==""){
		alert("简介未填写");
		return;
	}
	var potname = new Array();
	var zjiid = [];
	var bzbsum = [];
	var zjid = [];
	
	for(var v=0;v<zjsum;v++){
		potname[v] = $(".da_t_pots div:eq("+v+") a:eq(0)").html();
		zjiid[v] = $(".da_t_pots div:eq("+v+") a:eq(2)").html();
		bzbsum[v] = $(".da_t_pots div:eq("+v+") a:eq(1)").html();
		zjid[v] = $(".da_t_pots div:eq("+v+") a:eq(3)").html();
	}
	$.ajax({
		url: "dept_add",
		data:{
			deptname:deptname,
			deptid:deptid,
			stmid:empid,
			empid:emp,
			depttext:depttext,
			bunlxid:1,
			bunsum:potsum,
			potname:potname,
			zjiid:zjiid,
			bzbsum:bzbsum,
			zjid:zjid
		},
		async: false,
		traditional: true,
		success: function(data){
			alert("添加完成");
		}
	});
}
function closedeppt() {
	var text = '新建业务';
	var url = 'zyc/dept-add';
	adds(text,url);
}